{% extends 'base/nav.html' %}
{% load crispy_forms_tags %}

{% block title %}编辑景点 - 旅游舆情监测{% endblock %}

{% block content %}
<div class="container">
    <div class="row">
        <div class="col-md-10 col-md-offset-1">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <h3 class="panel-title">
                        <i class="fa fa-edit"></i> 编辑景点：{{ object.name }}
                    </h3>
                </div>
                <div class="panel-body">
                    <form method="post" enctype="multipart/form-data">
                        {% csrf_token %}
                        
                        <div class="row">
                            <div class="col-md-6">
                                {{ form.name|as_crispy_field }}
                            </div>
                            <div class="col-md-6">
                                {{ form.main_image|as_crispy_field }}
                                {% if object.main_image %}
                                <div class="mt-2">
                                    <small class="text-muted">当前图片：</small><br>
                                    <img src="{{ object.main_image.url }}" alt="当前图片" style="max-width: 100px; max-height: 100px;" class="img-thumbnail">
                                </div>
                                {% endif %}
                            </div>
                        </div>
                        
                        <div class="row">
                            <div class="col-md-4">
                                {{ form.province|as_crispy_field }}
                            </div>
                            <div class="col-md-4">
                                {{ form.city|as_crispy_field }}
                            </div>
                            <div class="col-md-4">
                                {{ form.location|as_crispy_field }}
                            </div>
                        </div>
                        
                        {{ form.description|as_crispy_field }}
                        
                        <div class="row">
                            <div class="col-md-6">
                                {{ form.categories|as_crispy_field }}
                            </div>
                            <div class="col-md-6">
                                {{ form.sentiment_tags|as_crispy_field }}
                            </div>
                        </div>
                        
                        {{ form.status|as_crispy_field }}
                        
                        <div class="attraction-stats mt-4 p-3 bg-light rounded">
                            <h5><i class="fa fa-line-chart"></i> 景点统计</h5>
                            <div class="row">
                                <div class="col-md-3">
                                    <strong>热度指数：</strong>{{ object.heat_index }}
                                </div>
                                <div class="col-md-3">
                                    <strong>评论数量：</strong>{{ object.review_count }}
                                </div>
                                <div class="col-md-3">
                                    <strong>情感得分：</strong>{{ object.avg_sentiment_score|floatformat:2 }}
                                </div>
                                <div class="col-md-3">
                                    <strong>创建时间：</strong>{{ object.created_at|date:"Y-m-d" }}
                                </div>
                            </div>
                        </div>
                        
                        <div class="form-group mt-4">
                            <button type="submit" class="btn btn-primary btn-lg">
                                <i class="fa fa-save"></i> 保存修改
                            </button>
                            <a href="{% url 'users:attraction_list' %}" class="btn btn-default">
                                <i class="fa fa-times"></i> 取消
                            </a>
                            <a href="{% url 'main:attraction_detail' object.pk %}" class="btn btn-info">
                                <i class="fa fa-eye"></i> 查看详情
                            </a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}